import 'package:get/get.dart';
import 'package:my_app/app/data/model/user.dart';
import 'package:my_app/app/data/services/api_service.dart';

/// dio_tool_api.dart
///
/// Created by fuchuanwei on Tue Feb 21 2023.
///
/// Description: Dio工具Api
///
class DioToolApi {
  final ApiService apiService = Get.find<ApiService>();

  Future getTest() async {
    final response = await apiService
        .get("/get", queryParameters: {"id": "1", "name": "f", "age": 18});
    return response.data;
  }

  Future postTest() async {
    final response = await apiService
        .post("/post", data: {"id": "1", "name": "f", "age": 18});
    return response.data;
  }

  Future putTest() async {
    final response =
        await apiService.put("/put", data: {"id": "1", "name": "f", "age": 18});
    return response.data;
  }

  Future deleteTest() async {
    final response = await apiService.delete("/delete");
    return response.data;
  }

  Future<User> getUser() async {
    final response = await apiService
        .get("/get", queryParameters: {"id": "1", "name": "张三", "age": 18});
    final data = response.data["args"];
    return User.fromJson(data);
  }
}
